package net.chenlin.dp.modules.business.service.impl;

import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.modules.business.dao.DeviceRegisterMapper;
import net.chenlin.dp.modules.business.entity.vo.deviceRegister.deviceRegisterListVo;
import net.chenlin.dp.modules.business.service.DeviceRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author Yangsm
 * @ClassName: DeviceRegisterServiceImpl
 * @Description: TODO
 * @date 2023年02月01日 16:49
 */
@Service
public class DeviceRegisterServiceImpl implements DeviceRegisterService {

    @Autowired
    private DeviceRegisterMapper deviceRegisterMapper;

    @Override
    public Page<deviceRegisterListVo> getDeviceList(Map<String, Object> params) {
        Query query = new Query(params);
        Page<deviceRegisterListVo> page = new Page<>(query);
        List<deviceRegisterListVo> list =  deviceRegisterMapper.getDeviceList(page, query);
        list.stream().forEach(vo -> {
            if(vo.getDeviceStatus().equals("0")){
                vo.setDeviceStatus("在线");
            }
            if(vo.getDeviceStatus().equals("1")){
                vo.setDeviceStatus("离线");
            }
            vo.setDeviceNo(vo.getDeviceNo()+"/"+vo.getDeviceBarCode());
        });
        return page;
    }
}
